#include<iostream>
using namespace std;
int swfx(int a){
	while(a!=0){
		if((a%10==2) || (a%10==4)){
			return 0;
		}
		a/=10;
	}
	return 1;
}
int main(){
	int n;
	cin>>n;
	int count=0;
	int k=0;
	for(int i=1;i<n/3;i++){
		for(int j=i+1;j<n-i-j;j++){
			k=n-i-j;
			if((swfx(i)==0) || (swfx(j)==0) || (swfx(k)==0)){
				continue;
			}
			else{
				count++;
			}
		}
	}
	cout<<count;
}
